home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 November / CPNL0711.ISO / boekhoud / finan / BADGER finance v1.0 beta 2.exe / xampplite / phpMyAdmin / libraries / tbl_properties.inc.php < prev    next >
PHP Script  |  2006-03-25  |  30KB  |  708 lines

  1. <?php
  2. /* $Id: tbl_properties.inc.php,v 1.5.2.1 2006/03/26 11:09:13 lem9 Exp $ */
  3. // vim: expandtab sw=4 ts=4 sts=4:
  4. // Check parameters
  5.  
  6. require_once('./libraries/common.lib.php');
  7. PMA_checkParameters(array('db', 'table', 'action', 'num_fields'));
  8.  
  9.  
  10. // Get available character sets and storage engines
  11. require_once('./libraries/mysql_charsets.lib.php');
  12. require_once('./libraries/storage_engines.lib.php');
  13.  
  14. if ($cfg['CtrlArrowsMoving']) {
  15.     ?>
  16. <script src="./js/keyhandler.js" type="text/javascript" language="javascript"></script>
  17. <script type="text/javascript" language="javascript">
  18. <!--
  19. var switch_movement = <?php echo $cfg['DefaultPropDisplay'] == 'horizontal' ? '0' : '1'; ?>;
  20. document.onkeydown = onKeyDownArrowsHandler;
  21. // -->
  22. </script>
  23.     <?php
  24. }
  25. // here, the div_x_7 represents a div id which contains
  26. // the default CURRENT TIMESTAMP checkbox and label
  27. // and, field_x_7a represents the checkbox itself
  28.  
  29. if (PMA_MYSQL_INT_VERSION >= 40102) {
  30.     ?>
  31. <script type="text/javascript" language="javascript">
  32. <!--
  33. function display_field_options(field_type, i) {
  34.     if (field_type == 'TIMESTAMP') {
  35.         getElement('div_' + i + '_7').style.display = 'block';
  36.     } else {
  37.         getElement('div_' + i + '_7').style.display = 'none';
  38.         getElement('field_' + i + '_7a').checked = false;
  39.     }
  40.     return true;
  41. }
  42. // -->
  43. </script>
  44. <?php } ?>
  45.  
  46. <form method="post" action="<?php echo $action; ?>" onsubmit="return checkTableEditForm(this, <?php echo $num_fields; ?>)" >
  47. <?php
  48. echo PMA_generate_common_hidden_inputs($db, $table);
  49. if ($action == 'tbl_create.php') {
  50.     ?>
  51.     <input type="hidden" name="reload" value="1" />
  52.     <?php
  53. } elseif ($action == 'tbl_addfield.php') {
  54.     ?>
  55.     <input type="hidden" name="field_where" value="<?php echo $field_where; ?>" />
  56.     <input type="hidden" name="after_field" value="<?php echo $after_field; ?>" />
  57.     <?php
  58. }
  59.  
  60. if (isset($num_fields)) {
  61.     ?>
  62.     <input type="hidden" name="orig_num_fields" value="<?php echo $num_fields; ?>" />
  63.     <?php
  64. }
  65.  
  66. if (isset($field_where)) {
  67.     ?>
  68.     <input type="hidden" name="orig_field_where" value="<?php echo $field_where; ?>" />
  69.     <?php
  70. }
  71.  
  72. if (isset($after_field)) {
  73.     ?>
  74.     <input type="hidden" name="orig_after_field" value="<?php echo $after_field; ?>" />
  75.     <?php
  76. }
  77.  
  78. if (isset($selected) && is_array($selected)) {
  79.     foreach ($selected AS $o_fld_nr => $o_fld_val) {
  80.         ?>
  81.     <input type="hidden" name="selected[<?php echo $o_fld_nr; ?>]" value="<?php echo urlencode($o_fld_val); ?>" />
  82.         <?php
  83.         if (!isset($true_selected)) {
  84.             ?>
  85.     <input type="hidden" name="true_selected[<?php echo $o_fld_nr; ?>]" value="<?php echo urlencode($o_fld_val); ?>" />
  86.             <?php
  87.         }
  88.  
  89.     }
  90.  
  91.     if (isset($true_selected) && is_array($true_selected)) {
  92.         foreach ($true_selected AS $o_fld_nr => $o_fld_val) {
  93.             ?>
  94.         <input type="hidden" name="true_selected[<?php echo $o_fld_nr; ?>]" value="<?php echo urlencode($o_fld_val); ?>" />
  95.             <?php
  96.         }
  97.     }
  98.  
  99. } elseif (isset($field)) {
  100.     ?>
  101.     <input type="hidden" name="orig_field" value="<?php echo urlencode($field); ?>" />
  102.     <input type="hidden" name="true_selected[] value="<?php echo (isset($orig_field) ? $orig_field : urlencode($field)); ?>" />
  103.     <?php
  104. }
  105.  
  106. $is_backup = ($action != 'tbl_create.php' && $action != 'tbl_addfield.php');
  107.  
  108. $header_cells = array();
  109. $content_cells = array();
  110.  
  111. $header_cells[] = $strField;
  112. $header_cells[] = $strType . ($GLOBALS['cfg']['ReplaceHelpImg'] ? PMA_showMySQLDocu('SQL-Syntax', 'Column_types') : '<br /><span style="font-weight: normal">' . PMA_showMySQLDocu('SQL-Syntax', 'Column_types') . '</span>');
  113. $header_cells[] = $strLengthSet . '<sup>1</sup>';
  114. if (PMA_MYSQL_INT_VERSION >= 40100) {
  115.     $header_cells[] = $strCollation;
  116. }
  117. $header_cells[] = $strAttr;
  118. $header_cells[] = $strNull;
  119. $header_cells[] = $strDefault . '<sup>2</sup>';
  120. $header_cells[] = $strExtra;
  121.  
  122.  
  123.  
  124. // lem9: We could remove this 'if' and let the key information be shown and
  125. // editable. However, for this to work, tbl_alter must be modified to use the
  126. // key fields, as tbl_addfield does.
  127.  
  128. if (!$is_backup) {
  129.     $header_cells[] = $cfg['PropertiesIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 'b_primary.png" width="16" height="16" alt="' . $strPrimary . '" title="' . $strPrimary . '" />' : $strPrimary;
  130.     $header_cells[] = $cfg['PropertiesIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 'b_index.png" width="16" height="16" alt="' . $strIndex . '" title="' . $strIndex . '" />' : $strIndex;
  131.     $header_cells[] = $cfg['PropertiesIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 'b_unique.png" width="16" height="16" alt="' . $strUnique . '" title="' . $strUnique . '" />' : $strUnique;
  132.     $header_cells[] = '---';
  133.     $header_cells[] = $cfg['PropertiesIconic'] ? '<img class="icon" src="' . $pmaThemeImage . 'b_ftext.png" width="16" height="16" alt="' . $strIdxFulltext . '" title="' . $strIdxFulltext . '" />' : $strIdxFulltext;
  134. }
  135.  
  136. require_once('./libraries/relation.lib.php');
  137. require_once('./libraries/transformations.lib.php');
  138. $cfgRelation = PMA_getRelationsParam();
  139.  
  140. $comments_map = array();
  141. $mime_map = array();
  142. $available_mime = array();
  143.  
  144. if ($cfgRelation['commwork'] || PMA_MYSQL_INT_VERSION >= 40100) {
  145.     $comments_map = PMA_getComments($db, $table);
  146.     $header_cells[] = $strComments;
  147.  
  148.     if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) {
  149.         $mime_map = PMA_getMIME($db, $table);
  150.         $available_mime = PMA_getAvailableMIMEtypes();
  151.  
  152.         $header_cells[] = $strMIME_MIMEtype;
  153.         $header_cells[] = $strMIME_transformation;
  154.         $header_cells[] = $strMIME_transformation_options . '<sup>3</sup>';
  155.     }
  156. }
  157.  
  158. // garvin: workaround for field_fulltext, because its submitted indizes contain
  159. //         the index as a value, not a key. Inserted here for easier maintaineance
  160. //         and less code to change in existing files.
  161. if (isset($field_fulltext) && is_array($field_fulltext)) {
  162.     foreach ($field_fulltext AS $fulltext_nr => $fulltext_indexkey) {
  163.         $submit_fulltext[$fulltext_indexkey] = $fulltext_indexkey;
  164.     }
  165. }
  166.  
  167. for ( $i = 0 ; $i <= $num_fields; $i++ ) {
  168.     $submit_null = FALSE;
  169.     if (isset($regenerate) && $regenerate == TRUE) {
  170.         // An error happened with previous inputs, so we will restore the data
  171.         // to embed it once again in this form.
  172.  
  173.         $row['Field']     = (isset($field_name) && isset($field_name[$i]) ? $field_name[$i] : FALSE);
  174.         $row['Type']      = (isset($field_type) && isset($field_type[$i]) ? $field_type[$i] : FALSE);
  175.         if (PMA_MYSQL_INT_VERSION >= 40100) {
  176.             $row['Collation']      = (isset($field_collation) && isset($field_collation[$i]) ? $field_collation[$i] : '');
  177.         }
  178.         $row['Null']      = (isset($field_null) && isset($field_null[$i]) ? $field_null[$i] : '');
  179.         if (isset($field_type[$i]) && $row['Null'] == '') {
  180.             $submit_null = TRUE;
  181.         }
  182.  
  183.         if (isset(${'field_key_' . $i}) && ${'field_key_' . $i} == 'primary_' . $i) {
  184.             $row['Key'] = 'PRI';
  185.         } elseif (isset(${'field_key_' . $i}) && ${'field_key_' . $i} == 'index_' . $i) {
  186.             $row['Key'] = 'MUL';
  187.         } elseif (isset(${'field_key_' . $i}) && ${'field_key_' . $i} == 'unique_' . $i) {
  188.             $row['Key'] = 'UNI';
  189.         } else {
  190.             $row['Key'] = '';
  191.         }
  192.  
  193.         $row['Default']   = (isset($field_default) && isset($field_default[$i]) ? $field_default[$i] : FALSE);
  194.         $row['Extra']     = (isset($field_extra) && isset($field_extra[$i]) ? $field_extra[$i] : FALSE);
  195.         $row['Comment']   = (isset($submit_fulltext) && isset($submit_fulltext[$i]) && ($submit_fulltext[$i] == $i) ? 'FULLTEXT' : FALSE);
  196.  
  197.         $submit_length    = (isset($field_length) && isset($field_length[$i]) ? $field_length[$i] : FALSE);
  198.         $submit_attribute = (isset($field_attribute) && isset($field_attribute[$i]) ? $field_attribute[$i] : FALSE);
  199.  
  200.         $submit_default_current_timestamp = (isset($field_default_current_timestamp) && isset($field_default_current_timestamp[$i]) ? TRUE : FALSE);
  201.  
  202.         if (isset($field_comments) && isset($field_comments[$i])) {
  203.             $comments_map[$row['Field']] = $field_comments[$i];
  204.         }
  205.  
  206.         if (isset($field_mimetype) && isset($field_mimetype[$i])) {
  207.             $mime_map[$row['Field']]['mimetype'] = $field_mimetype[$i];
  208.         }
  209.  
  210.         if (isset($field_transformation) && isset($field_transformation[$i])) {
  211.             $mime_map[$row['Field']]['transformation'] = $field_transformation[$i];
  212.         }
  213.  
  214.         if (isset($field_transformation_options) && isset($field_transformation_options[$i])) {
  215.             $mime_map[$row['Field']]['transformation_options'] = $field_transformation_options[$i];
  216.         }
  217.  
  218.     } elseif (isset($fields_meta) && isset($fields_meta[$i])) {
  219.         $row = $fields_meta[$i];
  220.     }
  221.  
  222.     // Cell index: If certain fields get left out, the counter shouldn't chage.
  223.     $ci = 0;
  224.     // Everytime a cell shall be left out the STRG-jumping feature, $ci_offset
  225.     // has to be incremented ($ci_offset++)
  226.     $ci_offset = -1;
  227.  
  228.     if ($is_backup) {
  229.         $backup_field = (isset($true_selected) && isset($true_selected[$i]) && $true_selected[$i] ? $true_selected[$i] : (isset($row) && isset($row['Field']) ? urlencode($row['Field']) : ''));
  230.         $content_cells[$i][$ci] = "\n" . '<input type="hidden" name="field_orig[]" value="' . $backup_field . '" />' . "\n";
  231.     } else {
  232.         $content_cells[$i][$ci] = '';
  233.     }
  234.  
  235.     $content_cells[$i][$ci] .= "\n" . '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '" type="text" name="field_name[]" size="10" maxlength="64" value="' . (isset($row) && isset($row['Field']) ? str_replace('"', '"', $row['Field']) : '') . '" class="textfield" title="' . $strField . '" />';
  236.     $ci++;
  237.     $content_cells[$i][$ci] = '<select name="field_type[]" id="field_' . $i . '_' . ($ci - $ci_offset) . '" ';
  238.     if (PMA_MYSQL_INT_VERSION >= 40102) {
  239.         $content_cells[$i][$ci] .= 'onchange="display_field_options(this.options[this.selectedIndex].value,' . $i .')" ';
  240.     }
  241.     $content_cells[$i][$ci] .= '>' . "\n";
  242.  
  243.     if (empty($row['Type'])) {
  244.         $row['Type'] = '';
  245.         $type        = '';
  246.     } else {
  247.         $type        = $row['Type'];
  248.     }
  249.     // set or enum types: slashes single quotes inside options
  250.     if (preg_match('@^(set|enum)\((.+)\)$@i', $type, $tmp)) {
  251.         $type   = $tmp[1];
  252.         $length = substr(preg_replace('@([^,])\'\'@', '\\1\\\'', ',' . $tmp[2]), 1);
  253.     } else {
  254.         // strip the "BINARY" attribute, except if we find "BINARY(" because
  255.         // this would be a BINARY or VARBINARY field type
  256.         $type   = preg_replace('@BINARY([^\(])@i', '', $type);
  257.         $type   = preg_replace('@ZEROFILL@i', '', $type);
  258.         $type   = preg_replace('@UNSIGNED@i', '', $type);
  259.  
  260.         if (strpos($type, '(')) {
  261.             $length = chop(substr($type, (strpos($type, '(') + 1), (strpos($type, ')') - strpos($type, '(') - 1)));
  262.             $type = chop(substr($type, 0, strpos($type, '(')));
  263.         } else {
  264.             $length = '';
  265.         }
  266.     } // end if else
  267.  
  268.     // some types, for example longtext, are reported as
  269.     // "longtext character set latin7" when their charset and / or collation
  270.     // differs from the ones of the corresponding database.
  271.     if (PMA_MYSQL_INT_VERSION >= 40100) {
  272.         $tmp = strpos($type, 'character set');
  273.         if ($tmp) {
  274.             $type = substr($type, 0, $tmp-1);
  275.         }
  276.     }
  277.  
  278.     if (isset($submit_length) && $submit_length != FALSE) {
  279.         $length = $submit_length;
  280.     }
  281.  
  282.     // rtrim the type, for cases like "float unsigned"
  283.     $type = rtrim($type);
  284.     $type_upper = strtoupper($type);
  285.  
  286.     $cnt_column_types = count($cfg['ColumnTypes']);
  287.     for ($j = 0; $j < $cnt_column_types; $j++) {
  288.         $content_cells[$i][$ci] .= '                <option value="'. $cfg['ColumnTypes'][$j] . '"';
  289.         if ($type_upper == strtoupper($cfg['ColumnTypes'][$j])) {
  290.             $content_cells[$i][$ci] .= ' selected="selected"';
  291.         }
  292.         $content_cells[$i][$ci] .= '>' . $cfg['ColumnTypes'][$j] . '</option>' . "\n";
  293.     } // end for
  294.  
  295.     $content_cells[$i][$ci] .= '    </select>';
  296.     $ci++;
  297.  
  298.     if ($is_backup) {
  299.         $content_cells[$i][$ci] = "\n" . '<input type="hidden" name="field_length_orig[]" value="' . urlencode($length) . '" />';
  300.     } else {
  301.         $content_cells[$i][$ci] = '';
  302.     }
  303.  
  304.     if (preg_match('@^(set|enum)$@i', $type)) {
  305.         $binary           = 0;
  306.         $unsigned         = 0;
  307.         $zerofill         = 0;
  308.         $length_to_display = htmlspecialchars($length);
  309.     } else {
  310.         $length_to_display = $length;
  311.         if (!preg_match('@BINARY[\(]@i', $row['Type']) && PMA_MYSQL_INT_VERSION < 40100) {
  312.             $binary           = stristr($row['Type'], 'binary');
  313.         } else {
  314.             $binary           = FALSE;
  315.         }
  316.         $unsigned         = stristr($row['Type'], 'unsigned');
  317.         $zerofill         = stristr($row['Type'], 'zerofill');
  318.     }
  319.  
  320.     $content_cells[$i][$ci] .= "\n" . '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '" type="text" name="field_length[]" size="8" value="' . str_replace('"', '"', $length_to_display) . '" class="textfield" />' . "\n";
  321.     $ci++;
  322.  
  323.     if (PMA_MYSQL_INT_VERSION >= 40100) {
  324.         $tmp_collation          = empty($row['Collation']) ? null : $row['Collation'];
  325.         $content_cells[$i][$ci] = PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'field_collation[]', 'field_' . $i . '_' . ($ci - $ci_offset), $tmp_collation, FALSE);
  326.         unset($tmp_collation);
  327.         $ci++;
  328.     }
  329.  
  330.     $content_cells[$i][$ci] = '<select style="font-size: 70%;" name="field_attribute[]" id="field_' . $i . '_' . ($ci - $ci_offset) . '">' . "\n";
  331.  
  332.     $attribute     = '';
  333.     if ($binary) {
  334.         $attribute = 'BINARY';
  335.     }
  336.     if ($unsigned) {
  337.         $attribute = 'UNSIGNED';
  338.     }
  339.     if ($zerofill) {
  340.         $attribute = 'UNSIGNED ZEROFILL';
  341.     }
  342.  
  343.     if (isset($submit_attribute) && $submit_attribute != FALSE) {
  344.         $attribute = $submit_attribute;
  345.     }
  346.  
  347.     // here, we have a TIMESTAMP that SHOW FULL FIELDS reports as having the
  348.     // NULL attribute, but SHOW CREATE TABLE says the contrary. Believe
  349.     // the latter.
  350.     if (isset($row['Field']) 
  351.     && isset($analyzed_sql[0]) 
  352.     && isset($analyzed_sql[0]['create_table_fields'])
  353.     && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['type'])
  354.     && $analyzed_sql[0]['create_table_fields'][$row['Field']]['type'] == 'TIMESTAMP' 
  355.     && $analyzed_sql[0]['create_table_fields'][$row['Field']]['timestamp_not_null'] == true) {
  356.         $row['Null'] = '';
  357.     }
  358.  
  359.  
  360.     // MySQL 4.1.2+ TIMESTAMP options
  361.     // (if on_update_current_timestamp is set, then it's TRUE)
  362.     if (isset($row['Field']) && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['on_update_current_timestamp'])) {
  363.         $attribute = 'ON UPDATE CURRENT_TIMESTAMP';
  364.     }
  365.     if ((isset($row['Field']) && isset($analyzed_sql[0]['create_table_fields'][$row['Field']]['default_current_timestamp']))
  366.      || (isset($submit_default_current_timestamp) && $submit_default_current_timestamp)  ) {
  367.         $default_current_timestamp = TRUE;
  368.     } else {
  369.         $default_current_timestamp = FALSE;
  370.     }
  371.  
  372.     // Dynamically add ON UPDATE CURRENT_TIMESTAMP to the possible attributes
  373.     if (PMA_MYSQL_INT_VERSION >= 40102 && !in_array('ON UPDATE CURRENT_TIMESTAMP', $cfg['AttributeTypes'])) {
  374.         $cfg['AttributeTypes'][] = 'ON UPDATE CURRENT_TIMESTAMP';
  375.     }
  376.  
  377.  
  378.     $cnt_attribute_types = count($cfg['AttributeTypes']);
  379.     for ($j = 0;$j < $cnt_attribute_types; $j++) {
  380.         if (PMA_MYSQL_INT_VERSION >= 40100 && $cfg['AttributeTypes'][$j] == 'BINARY') {
  381.             continue;
  382.         }
  383.         $content_cells[$i][$ci] .= '                <option value="'. $cfg['AttributeTypes'][$j] . '"';
  384.         if (strtoupper($attribute) == strtoupper($cfg['AttributeTypes'][$j])) {
  385.             $content_cells[$i][$ci] .= ' selected="selected"';
  386.         }
  387.         $content_cells[$i][$ci] .= '>' . $cfg['AttributeTypes'][$j] . '</option>' . "\n";
  388.     }
  389.  
  390.     $content_cells[$i][$ci] .= '</select>';
  391.     $ci++;
  392.  
  393.     $content_cells[$i][$ci] = '<select name="field_null[]" id="field_' . $i . '_' . ($ci - $ci_offset) . '">';
  394.  
  395.     if ((!isset($row) || empty($row['Null']) || $row['Null'] == 'NO' || $row['Null'] == 'NOT NULL') && $submit_null == FALSE) {
  396.         $content_cells[$i][$ci] .= "\n";
  397.         $content_cells[$i][$ci] .= '    <option value="NOT NULL" selected="selected" >not null</option>' . "\n";
  398.         $content_cells[$i][$ci] .= '    <option value="">null</option>' . "\n";
  399.     } else {
  400.         $content_cells[$i][$ci] .= "\n";
  401.         $content_cells[$i][$ci] .= '    <option value="" selected="selected" >null</option>' . "\n";
  402.         $content_cells[$i][$ci] .= '    <option value="NOT NULL">not null</option>' . "\n";
  403.     }
  404.  
  405.     $content_cells[$i][$ci] .= "\n" . '</select>';
  406.     $ci++;
  407.  
  408.     if (isset($row)
  409.       && !isset($row['Default']) && isset($row['Null']) && $row['Null'] == 'YES') {
  410.         $row['Default'] = 'NULL';
  411.     }
  412.  
  413.     if ($is_backup) {
  414.         $content_cells[$i][$ci] = "\n" . '<input type="hidden" name="field_default_orig[]" size="8" value="' . (isset($row) && isset($row['Default']) ? urlencode($row['Default']) : '') . '" />';
  415.     } else {
  416.         $content_cells[$i][$ci] = "\n";
  417.     }
  418.  
  419.     // for a TIMESTAMP, do not show CURRENT_TIMESTAMP as a default value
  420.     if (PMA_MYSQL_INT_VERSION >= 40102
  421.         && $type_upper == 'TIMESTAMP'
  422.         && $default_current_timestamp
  423.         && isset($row)
  424.         && isset($row['Default'])) {
  425.         $row['Default'] = '';
  426.     }
  427.  
  428.     $content_cells[$i][$ci] .= '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '" type="text" name="field_default[]" size="12" value="' . (isset($row) && isset($row['Default']) ? str_replace('"', '"', $row['Default']) : '') . '" class="textfield" />';
  429.     if (PMA_MYSQL_INT_VERSION >= 40102) {
  430.         if ($type_upper == 'TIMESTAMP') {
  431.             $tmp_display_type = 'block';
  432.         } else {
  433.             $tmp_display_type = 'none';
  434.             $default_current_timestamp = FALSE;
  435.         }
  436.         $content_cells[$i][$ci] .= '<br /><div id="div_' . $i . '_' . ($ci - $ci_offset) . '" style="white-space: nowrap; display: ' . $tmp_display_type . '"><input id="field_' . $i . '_' . ($ci - $ci_offset) . 'a" type="checkbox" name="field_default_current_timestamp[' . $i . ']"';
  437.         if ($default_current_timestamp) {
  438.             $content_cells[$i][$ci] .= ' checked="checked" ';
  439.         }
  440.         $content_cells[$i][$ci] .= ' /><label for="field_' . $i . '_' . ($ci - $ci_offset) . 'a" style="font-size: 70%;">CURRENT_TIMESTAMP</label></div>';
  441.     }
  442.     $ci++;
  443.  
  444.     $content_cells[$i][$ci] = '<select name="field_extra[]" id="field_' . $i . '_' . ($ci - $ci_offset) . '">';
  445.  
  446.     if (!isset($row) || empty($row['Extra'])) {
  447.         $content_cells[$i][$ci] .= "\n";
  448.         $content_cells[$i][$ci] .= '<option value=""></option>' . "\n";
  449.         $content_cells[$i][$ci] .= '<option value="AUTO_INCREMENT">auto_increment</option>' . "\n";
  450.     } else {
  451.         $content_cells[$i][$ci] .= "\n";
  452.         $content_cells[$i][$ci] .= '<option value="AUTO_INCREMENT">auto_increment</option>' . "\n";
  453.         $content_cells[$i][$ci] .= '<option value=""></option>' . "\n";
  454.     }
  455.  
  456.     $content_cells[$i][$ci] .= "\n" . '</select>';
  457.     $ci++;
  458.  
  459.  
  460.     // lem9: See my other comment about removing this 'if'.
  461.     if (!$is_backup) {
  462.         if (isset($row) && isset($row['Key']) && $row['Key'] == 'PRI') {
  463.             $checked_primary = ' checked="checked"';
  464.         } else {
  465.             $checked_primary = '';
  466.         }
  467.         if (isset($row) && isset($row['Key']) && $row['Key'] == 'MUL') {
  468.             $checked_index   = ' checked="checked"';
  469.         } else {
  470.             $checked_index   = '';
  471.         }
  472.         if (isset($row) && isset($row['Key']) && $row['Key'] == 'UNI') {
  473.             $checked_unique   = ' checked="checked"';
  474.         } else {
  475.             $checked_unique   = '';
  476.         }
  477.         if (empty($checked_primary)
  478.             && empty($checked_index)
  479.             && empty($checked_unique)) {
  480.             $checked_none = ' checked="checked"';
  481.         } else {
  482.             $checked_none = '';
  483.         }
  484.  
  485.         if ((isset($row) && isset($row['Comment']) && $row['Comment'] == 'FULLTEXT')) {
  486.             $checked_fulltext = ' checked="checked"';
  487.         } else {
  488.             $checked_fulltext = '';
  489.         }
  490.  
  491.         $content_cells[$i][$ci] = "\n" . '<input type="radio" name="field_key_' . $i . '" value="primary_' . $i . '"' . $checked_primary . ' title="' . $strPrimary . '" />';
  492.         $ci++;
  493.  
  494.         $content_cells[$i][$ci] = "\n" . '<input type="radio" name="field_key_' . $i . '" value="index_' . $i . '"' .  $checked_index . ' title="' . $strIndex . '" />';
  495.         $ci++;
  496.  
  497.         $content_cells[$i][$ci] = "\n" . '<input type="radio" name="field_key_' . $i . '" value="unique_' . $i . '"' .  $checked_unique . ' title="' . $strUnique . '" />';
  498.         $ci++;
  499.  
  500.         $content_cells[$i][$ci] = "\n" . '<input type="radio" name="field_key_' . $i . '" value="none_' . $i . '"' .  $checked_none . ' title="---" />';
  501.         $ci++;
  502.  
  503.         $content_cells[$i][$ci] = '<input type="checkbox" name="field_fulltext[]" value="' . $i . '"' . $checked_fulltext . ' title="' . $strIdxFulltext . '" />';
  504.         $ci++;
  505.     } // end if ($action ==...)
  506.  
  507.     // garvin: comments
  508.     if ($cfgRelation['commwork'] || PMA_MYSQL_INT_VERSION >= 40100) {
  509.         $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '" type="text" name="field_comments[]" size="12" value="' . (isset($row) && isset($row['Field']) && is_array($comments_map) && isset($comments_map[$row['Field']]) ?  htmlspecialchars($comments_map[$row['Field']]) : '') . '" class="textfield" />';
  510.         $ci++;
  511.     }
  512.  
  513.     // garvin: MIME-types
  514.     if ($cfgRelation['mimework'] && $cfg['BrowseMIME'] && $cfgRelation['commwork']) {
  515.         $content_cells[$i][$ci] = '<select id="field_' . $i . '_' . ($ci - $ci_offset) . '" size="1" name="field_mimetype[]">' . "\n";
  516.         $content_cells[$i][$ci] .= '    <option value=""></option>' . "\n";
  517.         $content_cells[$i][$ci] .= '    <option value="auto">auto-detect</option>' . "\n";
  518.  
  519.         if (is_array($available_mime['mimetype'])) {
  520.             foreach ($available_mime['mimetype'] AS $mimekey => $mimetype) {
  521.                 $checked = (isset($row) && isset($row['Field']) && isset($mime_map[$row['Field']]['mimetype']) && ($mime_map[$row['Field']]['mimetype'] == str_replace('/', '_', $mimetype)) ? 'selected ' : '');
  522.                 $content_cells[$i][$ci] .= '    <option value="' . str_replace('/', '_', $mimetype) . '" ' . $checked . '>' . htmlspecialchars($mimetype) . '</option>';
  523.             }
  524.         }
  525.  
  526.         $content_cells[$i][$ci] .= '</select>';
  527.         $ci++;
  528.  
  529.         $content_cells[$i][$ci] = '<select id="field_' . $i . '_' . ($ci - $ci_offset) . '" size="1" name="field_transformation[]">' . "\n";
  530.         $content_cells[$i][$ci] .= '    <option value="" title="' . $strNone . '"></option>' . "\n";
  531.         if (is_array($available_mime['transformation'])) {
  532.             foreach ($available_mime['transformation'] AS $mimekey => $transform) {
  533.                 $checked = (isset($row) && isset($row['Field']) && isset($mime_map[$row['Field']]['transformation']) && (preg_match('@' . preg_quote($available_mime['transformation_file'][$mimekey]) . '3?@i', $mime_map[$row['Field']]['transformation'])) ? 'selected ' : '');
  534.                 $tooltip = 'strTransformation_' . strtolower(preg_replace('@(\.inc\.php3?)$@', '', $available_mime['transformation_file'][$mimekey]));
  535.                 $tooltip = isset($$tooltip) ? $$tooltip : sprintf(str_replace('<br />', ' ', $strMIME_nodescription), 'PMA_transformation_' . $tooltip . '()');
  536.                 $content_cells[$i][$ci] .= '<option value="' . $available_mime['transformation_file'][$mimekey] . '" ' . $checked . ' title="' . htmlspecialchars($tooltip) . '">' . htmlspecialchars($transform) . '</option>' . "\n";
  537.             }
  538.         }
  539.  
  540.         $content_cells[$i][$ci] .= '</select>';
  541.         $ci++;
  542.  
  543.         $content_cells[$i][$ci] = '<input id="field_' . $i . '_' . ($ci - $ci_offset) . '" type="text" name="field_transformation_options[]" size="16" value="' . (isset($row) && isset($row['Field']) && isset($mime_map[$row['Field']]['transformation_options']) ?  htmlspecialchars($mime_map[$row['Field']]['transformation_options']) : '') . '" class="textfield" />';
  544.         //$ci++;
  545.     }
  546. } // end for
  547.  
  548. if ( is_array( $content_cells ) && is_array( $header_cells ) ) {
  549.     // last row is for javascript insert
  550.     $empty_row = array_pop( $content_cells );
  551.  
  552.     echo '<table id="table_columns">';
  553.     if ( $cfg['DefaultPropDisplay'] == 'horizontal' ) {
  554.         ?>
  555. <tr>
  556.         <?php foreach ( $header_cells as $header_val ) { ?>
  557.     <th><?php echo $header_val; ?></th>
  558.         <?php } ?>
  559. </tr>
  560.         <?php
  561.  
  562.         $odd_row = true;
  563.         foreach ( $content_cells as $content_row ) {
  564.             echo '<tr class="' . ( $odd_row ? 'odd' : 'even' ) . ' noclick">';
  565.             $odd_row = ! $odd_row;
  566.  
  567.             if ( is_array( $content_row ) ) {
  568.                 foreach ($content_row as $content_row_val) {
  569.                     ?>
  570.     <td align="center"><?php echo $content_row_val; ?></td>
  571.                     <?php
  572.                 }
  573.             }
  574.             echo '</tr>';
  575.         }
  576.     } else {
  577.         $i = 0;
  578.         $odd_row = true;
  579.         foreach ( $header_cells as $header_val ) {
  580.             echo '<tr class="' . ( $odd_row ? 'odd' : 'even' ) . ' noclick">';
  581.             $odd_row = ! $odd_row;
  582.             ?>
  583.     <th><?php echo $header_val; ?></th>
  584.             <?php
  585.             foreach ( $content_cells as $content_cell ) {
  586.                 if ( isset( $content_cell[$i] ) && $content_cell[$i] != '' ) {
  587.                     ?>
  588.     <td><?php echo $content_cell[$i]; ?></td>
  589.                     <?php
  590.                 }
  591.             }
  592.             echo '</tr>';
  593.             $i++;
  594.         }
  595.     }
  596.     ?>
  597. </table>
  598. <br />
  599.     <?php
  600. }
  601.  
  602. /**
  603.  * needs to be finished
  604.  *
  605.  *
  606. if ( $cfg['DefaultPropDisplay'] == 'horizontal' ) {
  607.     $new_field = '';
  608.     foreach ( $empty_row as $content_row_val ) {
  609.         $new_field .= '<td align="center">' . $content_row_val . '</td>';
  610.     }
  611.     ?>
  612. <script type="text/javascript" language="javascript">
  613. <!--
  614. var odd_row = <?php echo $odd_row; ?>;
  615.  
  616. function addField() {
  617.     var new_fields = document.getElementById('added_fields').value;
  618.     var new_field_container = document.getElementById('table_columns');
  619.     var new_field = '<?php echo preg_replace( '∩┐╜\s+∩┐╜', ' ', preg_replace( '∩┐╜\'∩┐╜', '\\\'', $new_field ) ); ?>';
  620.     var i = 0;
  621.     for ( i = 0; i < new_fields; i++ ) {
  622.         if ( odd_row ) {
  623.             new_field_container.innerHTML += '<tr class="odd">' + new_field + '</tr>';
  624.         } else {
  625.             new_field_container.innerHTML += '<tr class="even">' + new_field + '</tr>';
  626.         }
  627.         odd_row = ! odd_row;
  628.     }
  629.  
  630.     return true;
  631. }
  632. // -->
  633. </script>
  634.     <?php
  635. }
  636.  */
  637.  
  638. if ($action == 'tbl_create.php') {
  639.     ?>
  640.     <table>
  641.     <tr valign="top">
  642.         <th><?php echo $strTableComments; ?>: </th>
  643.         <td width="25"> </td>
  644.     <th><?php echo $strStorageEngine; ?>: <?php echo PMA_showMySQLDocu('Storage_engines', 'Storage_engines'); ?>
  645.         </th>
  646.     <?php
  647.     if ( PMA_MYSQL_INT_VERSION >= 40100 ) {
  648.         echo '        <td width="25"> </td>' . "\n"
  649.            . '        <th>' . $strCollation . ': </th>' . "\n";
  650.     }
  651.     ?>
  652.     </tr>
  653.     <tr><td><input type="text" name="comment" size="40" maxlength="80"
  654.                 value="<?php echo (isset($comment) ? $comment : ''); ?>"
  655.                 class="textfield" />
  656.         </td>
  657.         <td width="25"> </td>
  658.         <td>
  659. <?php echo PMA_generateEnginesDropdown('tbl_type', null, FALSE, (isset($GLOBALS['tbl_type']) ? $GLOBALS['tbl_type'] : null), 3); ?>
  660.         </td>
  661.         <?php
  662.         if ( PMA_MYSQL_INT_VERSION >= 40100 ) {
  663.             echo '        <td width="25"> </td>' . "\n"
  664.                . '        <td>' . "\n"
  665.                . PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'tbl_collation', null, (isset($tbl_collation) ? $tbl_collation : null), FALSE, 3)
  666.                . '        </td>' . "\n";
  667.         }
  668.     ?>
  669.     </tr>
  670.     </table>
  671.     <br />
  672.     <?php
  673. } // end if ($action == 'tbl_create.php')
  674. ?>
  675.  
  676. <fieldset class="tblFooters">
  677.     <input type="submit" name="do_save_data" value="<?php echo $strSave; ?>" />
  678. <?php if ($action == 'tbl_create.php' || $action == 'tbl_addfield.php') { ?>
  679.     <?php echo $GLOBALS['strOr']; ?>
  680.     <?php echo sprintf( $strAddFields, '<input type="text" id="added_fields" name="added_fields" size="2" value="1" onfocus="this.select()" />' ); ?>
  681.     <input type="submit" name="submit_num_fields"
  682.         value="<?php echo $GLOBALS['strGo']; ?>"
  683. <?php /*        onclick="if ( addField() ) return false;" */ ?>
  684.         onclick="return checkFormElementInRange(this.form, 'added_fields', '<?php echo str_replace('\'', '\\\'', $GLOBALS['strInvalidFieldAddCount']); ?>', 1)"
  685.         />
  686. <?php } ?>
  687. </fieldset>
  688.  
  689. </form>
  690.  
  691. <div class="notice">
  692.     <p> <a name="footnoote_setenumval"><sup>1</sup></a> <?php echo $strSetEnumVal; ?></p>
  693.     <p> <a name="footnoote_defaultvalue"><sup>2</sup></a> <?php echo $strDefaultValueHelp; ?></p>
  694. <?php
  695. if ($cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME']) {
  696.     echo '<p> <a name="footnoote_mime"><sup>3</sup></a> ' . $strMIME_transformation_options_note . '</p>';
  697.     echo '<p> ';
  698.     printf( $strMIME_transformation_note,
  699.             '<a href="transformation_overview.php?'
  700.             . PMA_generate_common_url($db, $table) . '" target="_blank">',
  701.             '</a>' );
  702.     echo '</p>';
  703. }
  704. ?>
  705. </div>
  706.  
  707. <center><?php echo PMA_showMySQLDocu('SQL-Syntax', 'CREATE_TABLE'); ?></center>
  708.